package com.agileai.pm.module.base.service;

import java.util.List;

import com.agileai.domain.DataParam;
import com.agileai.domain.DataRow;
import com.agileai.hotweb.bizmoduler.core.StandardServiceImpl;
import com.agileai.util.StringUtil;

public class TeamStaffManageImpl
        extends StandardServiceImpl
        implements TeamStaffManage {
    public TeamStaffManageImpl() {
        super();
    }
    
	public void insertStaffInfo(DataParam param) {
		String statementId = sqlNameSpace+"."+"insertStaffInfo";
		this.daoHelper.insertRecord(statementId, param);
	}

	@Override
	public void insertUserGrp(DataParam param) {
		String statementId = sqlNameSpace+"."+"insertUserGrp";
		this.daoHelper.insertRecord(statementId, param);
	}

	@Override
	public void updateStaffInfo(DataParam param) {
		String statementId = sqlNameSpace+"."+"updateStaffInfo";
		this.daoHelper.updateRecord(statementId, param);
	}

	@Override
	public int getMaxNum(DataParam param) {
		String statementId = sqlNameSpace+"."+"getMaxNum";
    	DataRow result = this.daoHelper.getRecord(statementId, param);
    	int num = result.getInt("USER_SORT");
    	String sort = String.valueOf(num);
    	if(StringUtil.isNullOrEmpty(sort)){
    		num = 1;
    	}else{
    		num++;
    	}
		return num;
	}

	@Override
	public void deleteStaffInfo(DataParam param) {
		String statementId = sqlNameSpace+"."+"deleteStaffInfo";
		this.daoHelper.deleteRecords(statementId, param);
	}

	@Override
	public void delectGrp(DataParam param) {
		String statementId = sqlNameSpace+"."+"delectGrp";
		this.daoHelper.deleteRecords(statementId, param);
	}

	@Override
	public void insertUserRole(DataParam param) {
		String statementId = sqlNameSpace+"."+"insertUserRole";
		this.daoHelper.insertRecord(statementId, param);
		
	}
	@Override
	public List<DataRow> findUserProjectRelRecords(String userId){
		String statementId = sqlNameSpace+"."+"findUserProjectRelRecords";
		DataParam param = new DataParam();
		param.put("USER_ID",userId);
		return this.daoHelper.queryRecords(statementId, param);
	}

	@Override
	public void deleteUserRole(String userId,String rgId) {
		String statementId = sqlNameSpace+"."+"deleteUserRole";
		DataParam param = new DataParam();
		param.put("USER_ID",userId);
		param.put("RG_ID",rgId);
		this.daoHelper.deleteRecords(statementId, param);
	}	
}
